package com.atl.controller.wx.admin;

import com.atl.common.BaseContext;
import com.atl.common.BaseResponse;
import com.atl.common.ErrorCode;
import com.atl.enity.po.AgentUser;
import com.atl.enity.po.BankCard;
import com.atl.enity.wx.admin.dto.AgentUserLoginDTO;
import com.atl.enity.wx.admin.dto.BankCardDTO;
import com.atl.service.IBankCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javafx.scene.layout.Background;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author: 临晖
 * @since: 2024-06-26
 */

@RestController
@RequestMapping("/wx/admin/backcard")
@Api(tags = "银行卡")
@Slf4j
public class WXBankCardController {


    @Resource
    private IBankCardService bankCardService;


    /**
     *
     * 添加银行卡
     *
     * @param bankCardDTO 用户传参
     * @param request http
     * @return 返回脱敏用户信息
     */
    @ApiOperation("绑定银行卡")
    @PostMapping("/add")
    public BaseResponse addBankCard(@RequestBody BankCardDTO bankCardDTO, HttpServletRequest request) {
        Long id = BaseContext.getId();
        //校验参数
        if (bankCardDTO == null) {
            return BaseResponse.errorResult( ErrorCode.ARGUMENT_ERROR);
        }

        BankCard bankCard = new BankCard();

        BeanUtils.copyProperties(bankCardDTO, bankCard);

        bankCard.setStockUserId(id);
        bankCard.setIsDeleted(0);



        //添加
        boolean save = bankCardService.save(bankCard);

        return BaseResponse.okResult(save);

    }



}
